package com.yifeng.service.impl;

import com.yifeng.dao.PermissionMapper;
import com.yifeng.po.Permission;
import com.yifeng.service.IPermissionService;
import com.yifeng.util.BlogResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl extends BaseServiceImpl<Permission> implements IPermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    public List<Permission> findUserPermissionsByLoginUserId(Long loginUserId) {
        return permissionMapper.loadUserPermissionsByLoginUserId(loginUserId);
    }

    public List<Permission> findPermissionsByRoleId(Long roleId) {
        return permissionMapper.loadPermissionsByRoleId(roleId);
    }

    public BlogResult getCount() {
        Integer result = permissionMapper.getAllCount();
        return new BlogResult(200,"OK",result);
    }

    public BlogResult getParent() {
        return new BlogResult(200,"OK",permissionMapper.getParent());
    }
}
